fix(#3464): override permalink use the front-matter #4359
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What does it do?
The PR closes #1158, closes #1813, closes #3464
#3464 (comment)
hexo/lib/plugins/processor/post.js
Lines 123 to 126 in edef5c2
Originally, during the processing of the post, the
permalink
defined in the front-matter which isdata.permalink
, will overridedata.slug
anddata.permalink
will be deleted.And, in
post_permalink
filter,data.slug
will be used to getname
andtitle
property:hexo/lib/plugins/filter/post_permalink.js
Lines 15 to 16 in edef5c2
So if I got a post:
source/_posts/i-love-hexo/hello.md
, I will get:i-love-hexo/hello
hello
If I then defines
permalink
aspermalink-test/hi.md
, I will get:permalink-test/hi
hi
.I don't know why it is designed like this. Maybe using the
permalink
to override the relative path undersource/_posts
. But it doesn't make any sense - why I have to override the relative path? I could just create required directories undersource/_posts
and it will be fine.Also, the behavior of
Post
is different fromPage
, whichpermalink
in the front-matter is truly able to override thehexo.config.permalink
. And that behavior is what user really want.So in this PR, I made a few changes toward post processor and
post_permalink
filter.As the behavior of the
permalink
in the front-matter has changed, thus the PR is still considered as a Breaking ChangeHow to test
Screenshots
Pull request tasks